﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NCT.MRS.DataAccessLayer.Entities;

namespace NCT.MRS.DataAccessLayer.Configurations
{
    public class ClientConfiguration : EntityTypeConfiguration<Client>
    {
        public ClientConfiguration()
        {
            HasKey(P => P.Id);

            Property(P => P.RegistrationId).IsRequired().HasMaxLength(50);
            Property(P => P.FirstName).IsRequired().HasMaxLength(30);
            Property(P => P.LastName).IsRequired().HasMaxLength(30);
            Property(P => P.MiddleName).IsOptional().HasMaxLength(30);
            Property(P => P.Gender).IsRequired();
            Property(P => P.IsSenior).IsRequired();

            HasRequired(P => P.ModifiedByUser).WithMany().HasForeignKey(P => P.ModifiedByUserId).WillCascadeOnDelete(false);

            HasMany(P => P.TestRequests).WithRequired(P => P.Client).HasForeignKey(P => P.ClientId);
        }
    }
}
